import argparse
import os
import tqdm
from my_io import read_pickle, write_pickle


def main(arg):
    os.path.exists(arg.datasets_path)
    dataset_paths = os.listdir(arg.datasets_path)
    post_fixs = ['train', 'val', 'test', 'trainval']
    for dataset_path in tqdm.tqdm(dataset_paths):
        if dataset_path[:2] != "__":
            continue
        for post_fix in post_fixs:
            pkl_path = os.path.join(arg.datasets_path, dataset_path, 'data_base', 'infos_' + post_fix + '.pkl')
            buffer = read_pickle(pkl_path)
            for key, value in buffer.items():
                if value['camera']=={}:
                    print(value['lidar']['path'])
                break
            pass
            # for key, value in buffer.items():
            #     if 'data_info' not  in value:
            #         value["data_info"] = {
            #             "type": 'hw'
            #         }
            # write_pickle(buffer, pkl_path)



if __name__ == '__main__':
    parser = argparse.ArgumentParser(description='editor')
    parser.add_argument('--datasets_path', type=str,
                        # default='/media/zwh/ZWH4T/ZWH/Dataset3d/pandarset_final')
                        default='/media/adt/T7/ZWH/docker/files/data/carla')
    arg = parser.parse_args()
    main(arg)
